<?php

namespace Mallocu\NuitInfoBundle\Repository;

use Doctrine\ORM\EntityRepository;

/**
 * Mallocu\NuitInfoBundle\Repository\MonumentRepository
 *
 * @author Rémi PIOTAIX <remi.piotaix@gmail.com>
 */
class MonumentRepository extends EntityRepository {

    public function getMonumentsPageAccueil() {
        $monuments = $this->getMonumentsImage();
        $manquants = 40 - count($monuments);

        $qb2 = $this->createQueryBuilder('m')->setMaxResults($manquants);

        return array_merge($monuments, $qb2->getQuery()->execute());
    }

    public function getMonumentsImage() {
        $qb = $this->createQueryBuilder('m');
        $qb->innerJoin('m.images', 'i')
                ->setMaxResults(40);

        return $qb->getQuery()->execute();
    }

}

?>
